/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Resources;

import java.io.IOException;
import javax.microedition.lcdui.Image;

/**
 *
 * @author ThanhTrung
 */
public class Resource {

    public static Image[] images;

    public static Image[] load(String[] img) {
        images = new Image[img.length];
        for (int m = 0; m < img.length; m++) {
            try {
                images[m] = Image.createImage(img[m]);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return images;
    }

    public static void unload(Image[] imgs) {
        if (imgs == null) {
            return;
        }
        for (int i = 0; i < imgs.length; i++) {
            imgs[i] = null;
        }
    }

    public static Image getImage(String[] images, int index) {
        Image img = null;
        try {
            img = Image.createImage(images[index]);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return img;
    }
}
